import Vue from 'vue'
import Router from 'vue-router'
import routes from "./index.config"

Vue.use(Router)

let router = new Router({
  routes,
})

// 导航守卫
router.beforeEach((to, from, next) => {
  if (localStorage.getItem('token') || to.name == "login") {
    next()
  } else {
    next({ path: '/' })
  }
})

export default router